getApp();

var t = require("../../utils/util.js"), e = null;

Page({
    data: {
        motto: "Hello World",
        couponList: [],
        img:'',
        userInfo: {},
        navigatorTitle: "观看视频获取积分",
        hasUserInfo: !1,
        canIUse: wx.canIUse("button.open-type.getUserInfo"),
        canIUseGetUserProfile: !1,
        canIUseOpenData: wx.canIUse("open-data.type.userAvatarUrl") && wx.canIUse("open-data.type.userNickName")
    },

    onLoad: function() {
        var a = this;
        var integral = wx.getStorageSync("integral");
        var pay = wx.getStorageSync("pay");
        var userId = wx.getStorageSync("userId");
		    var token = wx.getStorageSync("userToken");
        var adUnitId = integral.adunit1;
        var img = integral.video_cover;
        a.setData({
            tmplIds: adUnitId,
            img:img
        });
        var s = {
          uid:userId,
		      token:token
        };
        var n = this, o = wx.getSystemInfoSync();
        wx.createRewardedVideoAd && ((e = wx.createRewardedVideoAd({
            adUnitId: adUnitId
        })).onLoad(function() {}), e.onClose(function(e) {
            e && e.isEnded || void 0 === e ? n.data.selectedItem ? (wx.showToast({
                title: "恭喜您完成任务，赶紧领卷去吧！",
                icon: "none"
            }), wx.navigateToMiniProgram({
                appId: n.data.selectedItem.appId,
                path: n.data.selectedItem.path,
                success: function(t) {}
            })) : t.requestGet("/app/Exp/reward",s, function(t) {
                0 === t.data.c && (0 == t.data.d.money ? wx.showModal({
                    title: "温馨提示",
                    content: "今天您已经获取了积分，每天可以免费获取一次哦！",
                    showCancel: !1,
                    confirmText: "我知道了"
                }) : t.data.d.money > 0 && wx.showModal({
                    title: "积分到账",
                    content: "恭喜! " + t.data.d.moneyYuan + " 积分已经到账",
                    showCancel: !1,
                    confirmText: "立即使用",
                    success: function(t) {
                        t.confirm && wx.switchTab({
                            url: "/pages/index/index"
                        });
                    }
                }));
            }, function() {}) : wx.showModal({
                title: "温馨提示",
                content: "看完视频才能领取奖励哦！",
                showCancel: !1,
                confirmText: "我知道了"
            });
        }), e.onError(function(t) {
            return console.log(t.errMsg);
        }));
        var a = {
            iPhoneX: o.model.indexOf("iPhone X") >= 0,
            windowWidth: o.windowWidth,
            windowHeight: o.windowHeight,
            pxRpx: 750 / o.windowWidth,
            navH: o.statusBarHeight + 46
        };
        this.setData({
            sysInfo: a
        }), wx.getUserProfile && this.setData({
            canIUseGetUserProfile: !0
        }), this.renderData();
    },
    renderData: function() {
        var e = this;
        t.requestGet("/app/Exp/couponViewList", null, function(t) {
            console.log(t.data), e.setData({
                couponList: t.data.d.list
            });
        }, function() {});
    },
    goDetail: function(t) {
        var e = t.currentTarget.dataset.item;
        wx.navigateToMiniProgram({
            appId: e.appId,
            path: e.path,
            success: function(t) {}
        });
    },
    get_jili: function(t) {
        this.setData({
            selectedItem: null
        }), console.log(t), e && e.show().catch(function() {
            e.load().then(function() {
                return e.show();
            }).catch(function(t) {
                console.log("激励视频 广告显示失败");
            });
        });
    },
    couponsJiLi: function(t) {
        var n = t.currentTarget.dataset.item;
        this.setData({
            selectedItem: n
        }), e && e.show().catch(function() {
            e.load().then(function() {
                return e.show();
            }).catch(function(t) {
                console.log("激励视频 广告显示失败");
            });
        });
    },
    onShareAppMessage: function() {
        return {
            title: "看视频获取积分",
            imageUrl: "/static/imag/com-icon.png",
            path: "/pages/coupon/index"
        };
    }
});